import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from "path";

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src'),
      'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js'
    },
    extensions: ['.js', '.json', '.ts', '.vue']
  },
  base:'./', 
  esbuild:{
    charset:'ascii'
  },
  build: {
    outDir: 'dist_compile/prod',
    rollupOptions: {
      output: {
        manualChunks(id) {
          if (id.includes('node_modules')) {
            return id.toString().split('node_modules/')[1].split('/')[0].toString()
          }
        }
      }
    }
  },
  server:{
    proxy:{
      '/dev-api':{
        target:'http://fls-aflm-test.paic.com.cn/service/material',
        changeOrigin:true,
        rewrite:(path)=>path.replace(/^\/dev-api/,'')
      },
      '/local-api1':{
        target:'http://10.188.113.22:9092',
        changeOrigin:true,
        rewrite:(path)=>path.replace(/^\/local-api1/,'')
      },
      '/local-api2':{
        target:'http://10.130.66.153:9092',
        changeOrigin:true,
        rewrite:(path)=>path.replace(/^\/local-api2/,'')
      }
    }
  }
})
